﻿@model Model.AppUserList
@{
    ViewBag.Title = "PrintOrderInfo";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript" src="../../Scripts/LodopFuncs.js"></script>
    <script type="text/javascript" src="../../Scripts/PrintModel.js"></script>
    <script type="text/javascript" src="http://localhost:8000/CLodopfuncs.js?priority=1"></script>
    <object id="LODOP_OB" classid="clsid:2105C259-1E0C-4534-8141-A753534CB4CA" width="0" height="0">
        <embed id="LODOP_EM" type="application/x-print-lodop" width="0" height="0" />
    </object>
    <script type="text/javascript">
        var LODOP = getLodop(document.getElementById('LODOP_OB'), document.getElementById('LODOP_EM'));
        function getStatusValue(ValueType, ValueIndex, oResultOB) {
            LODOP = getLodop();
            if (LODOP.CVERSION) LODOP.On_Return = function (TaskID, Value) { oResultOB.value = Value; };
            var strResult = LODOP.GET_VALUE(ValueType, ValueIndex);
            if (!LODOP.CVERSION) return strResult; else return "";
        };
        $(document).ready(function () {
            var curr_time = new Date();
            var strDate = curr_time.getFullYear() + "-";
            strDate += curr_time.getMonth() + 1 + "-";
            strDate += curr_time.getDate();
            $("#RationStartDate").datebox("setValue", strDate);
            $("#RationEndDate").datebox("setValue", strDate);
            $('#DeliverArea').combobox('setValue', '0');
            $('#CustomerPayType').combobox('setValue', '0');

            InitGrid();

        });

        HandleDom.ClassTriggerClick("icon-preview", function () {
            Preview();
        });
        HandleDom.ClassTriggerClick("icon-printer", function () {
            Print();
        });


        //初始化数据
        function InitGrid() {
            var startDate = $('#RationStartDate').datebox('getValue');
            var OrderNo = $('#txtOrderNo').val();
            var selArea = $("#DeliverArea").combobox('getValue');//所属区域
            //var batchno = $("#selBatch  option:selected").val();//波次
            var batchno = $('#selBatch').val();
            var OrderStatus = $("#OrderStatus option:selected").val();//订单状态
            var OrderFrom = $('#txtOrderFrom').val();
            var OrderEnd = $('#txtOrderEnd').val();
            var lstGOODSCODE = $("#GOODSCODE").combobox('getValues');
            var GOODSCODE = "";
            for (var i = 0; i < lstGOODSCODE.length; i++) {
                GOODSCODE = GOODSCODE + "'" + lstGOODSCODE[i] + "',";
            }
            queryParams = {
                startDate: startDate,
                OrderNo: OrderNo,
                selArea: selArea,
                batchno: batchno,
                OrderStatus: OrderStatus,
                OrderFrom: OrderFrom,
                OrderEnd: OrderEnd,
                GOODSCODE: GOODSCODE
            }
            HandleData.InitDataGrid('dg', '/PrintOrderInfo/InitJsonResult', 'toolbar', queryParams, 'SHEETID', false, function (data) { },
                function (rowIndex, rowData) {//双击
                    edit(rowData);
                });
        }
        //打印订单标签
        function Print() {
            var form = $('#query');
            $('#hiddenGOODSCODE').val();
            var fjstartDate = $('#RationStartDate').datebox('getValue');
            var OrderNo = $('#txtOrderNo').val();
            var selArea = $("#DeliverArea").combobox('getValue');//所属区域
            //var batchno = $("#selBatch  option:selected").val();//波次
            var batchno = $('#selBatch').val();
            var OrderStatus = $("#OrderStatus option:selected").val();//订单状态
            var OrderFrom = $('#txtOrderFrom').val();
            var OrderEnd = $('#txtOrderEnd').val();
            var lstGOODSCODE = $("#GOODSCODE").combobox('getValues');
            var GOODSCODE = "";
            for (var i = 0; i < lstGOODSCODE.length; i++) {
                GOODSCODE = GOODSCODE + "'" + lstGOODSCODE[i] + "',";
            }
            var IsPrintCard = lstGOODSCODE.length > 0 ? 1 : 0;
            $('#hiddenGOODSCODE').val(GOODSCODE);
            form.form('submit', {
                url: '@Url.Content("~/PrintOrderInfo/ExporterExcelDetail")' + "?RationStartDate=" + fjstartDate + "&OrderNo=" + OrderNo + "&DeliverArea=" + selArea + "&selBatch=" + batchno + "&OrderStatus=" + OrderStatus + "&OrderFrom=" + OrderFrom + "&OrderEnd=" + OrderEnd + "&GOODSCODE=" + GOODSCODE,
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        PrintContent(data.info, 0, IsPrintCard);
                    }
                    else {
                        alert(data.msg);
                    }
                }
            });
        }
        function Preview() {
            var form = $('#query');
            $('#hiddenGOODSCODE').val();
            var fjstartDate = $('#RationStartDate').datebox('getValue');
            var OrderNo = $('#txtOrderNo').val();
            var selArea = $("#DeliverArea").combobox('getValue');//所属区域
            //var batchno = $("#selBatch  option:selected").val();//波次
            var batchno = $('#selBatch').val();
            var OrderStatus = $("#OrderStatus option:selected").val();//订单状态
            var OrderFrom = $('#txtOrderFrom').val();
            var OrderEnd = $('#txtOrderEnd').val();
            var lstGOODSCODE = $("#GOODSCODE").combobox('getValues');
            var GOODSCODE = "";
            for (var i = 0; i < lstGOODSCODE.length; i++) {
                GOODSCODE = GOODSCODE + "'" + lstGOODSCODE[i] + "',";
            }
            var IsPrintCard = lstGOODSCODE.length > 0 ? 1 : 0;
            $('#hiddenGOODSCODE').val(GOODSCODE);
            form.form('submit', {
                url: '@Url.Content("~/PrintOrderInfo/ExporterExcelDetail")' + "?RationStartDate=" + fjstartDate + "&OrderNo=" + OrderNo + "&DeliverArea=" + selArea + "&selBatch=" + batchno + "&OrderStatus=" + OrderStatus + "&OrderFrom=" + OrderFrom + "&OrderEnd=" + OrderEnd + "&GOODSCODE=" + GOODSCODE + "&Ispreview=1",
                success: function (data) {
                    eval('data=' + data);
                    if (data.success) {
                        PrintContent(data.info, 1, IsPrintCard);
                    }
                    else {
                        alert(data.msg);
                    }
                }
            });
        }


    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>
                        配送时间:
                    </td>
                    <td>
                        <input class="easyui-datebox" id="RationStartDate" name="RationStartDate" style="width: 140px;" />
                    </td>
                    <td>
                        区域:
                    </td>
                    <td>
                        <input id="DeliverArea" class="easyui-combobox" name="DeliverArea" style="width: 155px;" data-options="required:true,valueField:'fieldvalue',textField:'lookup',url:'@Url.Action("AreaList", "PrintDeliOrder", new { IsSetAll = "0" })',editable:false">
                    </td>
                    <td>
                        批次:
                    </td>
                    <td>
                        <input id="selBatch" name="selBatch" style="width: 154px" />
                    </td>
                    <td>
                        <input id="hiddenGOODSCODE" name="hiddenGOODSCODE" type="hidden" />
                        <span>需打印充值卡: </span>
                        <input id="GOODSCODE" class="easyui-combobox"
                               name="GOODSCODE"
                               url="@Url.Action("RechargeCardList", "PrintDeliOrder")"
                               valueField="GOODSCODE"
                               textField="GOODSNAME"
                               multiple="multiple"
                               panelHeight="auto"></td>
                    <td>

                    </td>
                </tr>
                <tr>
                    <td>
                        订单号:
                    </td>
                    <td>
                        <input id="txtOrderNo" name="txtOrderNo" style="width: 154px" />

                    </td>
                    <td>
                        订单状态:
                    </td>
                    <td>
                        <select id="OrderStatus">
                            <option value="0">--全部--</option>
                            <option value="1" selected="selected">未取消</option>
                            <option value="2">已取消</option>
                        </select>

                    </td>
                    <td>
                        订单序列:
                    </td>
                    <td>
                        <input id="txtOrderFrom" name="txtOrderFrom" style="width: 54px" />~
                        <input id="txtOrderEnd" name="txtOrderEnd" style="width: 54px" />

                    </td>
                    <td align="center">
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid();">查询</a>
                    </td>
                </tr>
                <tr hidden="hidden">
                    <td>
                        <input id="S1" />
                    </td>
                    <td>
                        <input id="S2" />
                    </td>
                    <td><a id="btnPrint1" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="document.getElementById('S2').value=getStatusValue('PRINT_STATUS_OK',document.getElementById('S1').value,document.getElementById('S2'))">打印结果</a></td>
                    <td>
                        <input id="S3" />
                    </td>
                    <td><a id="btnPrint2" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="document.getElementById('S3').value=getStatusValue('PRINT_STATUS_TEXT',document.getElementById('S1').value,document.getElementById('S3'))">打印状态</a></td>
                    <td>
                        <input id="S4" />
                    </td>
                    <td><a id="btnPrint3" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="document.getElementById('S4').value=getStatusValue('PRINT_STATUS_TOTAL_PAGES',document.getElementById('S1').value,document.getElementById('S4'))">打印总页数</a></td>
                    <td>
                        <input id="S5" />
                    </td>
                    <td><a id="btnPrint4" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="document.getElementById('S5').value=getStatusValue('PRINT_STATUS_LIST',document.getElementById('S1').value,document.getElementById('S5'))">打印状态变化</a></td>

                </tr>
            </table>
        </form>
    </div>

    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="生产批次订单" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'APPORDERNO',width:50">批次号</th>
                    <th data-options="field:'SHEETID',width:100">订单号</th>
                    <th data-options="field:'DISTRICT',width:60">区域</th>
                    <th data-options="field:'CONSIGNEEADD',width:150">配送地址</th>
                    <th data-options="field:'RATIONDATE',width:100,sortable:true,formatter:function(value, rowData, rowIndex){ return FormatData.formatDate(value);}">配送日期</th>
                    <th data-options="field:'RATIONTIME',width:50">配送时间</th>
                    <th data-options="field:'PAYTYPE',width:50">支付方式</th>
                    <th data-options="field:'CONSIGNEE',width:50">收货人</th>
                    <th data-options="field:'MOBILE',width:50">联系方式</th>
                    <th data-options="field:'TOTALSALEVALUE',width:40">总金额</th>
                    <th data-options="field:'TICKETNO',width:50">票号</th>
                </tr>
            </thead>
        </table>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =false },
              new FunctionModule(){Name = "Edit",IsEnable =false },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =false },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =false },
              new FunctionModule(){Name = "AllEdit",IsEnable =false },
              new FunctionModule(){Name = "Preview",IsEnable =true },
              new FunctionModule(){Name = "Printer",IsEnable =true },

            }
        }
    }
})

</body>
